package sandbox.util;

import org.apache.log4j.Logger;

/**
 * Набор полезных методов для логгирования
 */
public class LogUtils {

    private LogUtils() {}

    public static void debug(Object object, String logMsg) {
        Logger.getLogger(object.getClass()).debug(logMsg);
    }

    public static void debug(Object object, String logMsg, Throwable throwable) {
        Logger.getLogger(object.getClass()).debug(logMsg, throwable);
    }

    public static void info(Object object, String logMsg) {
        Logger.getLogger(object.getClass()).info(logMsg);
    }

    public static void info(Object object, String logMsg, Throwable throwable) {
        Logger.getLogger(object.getClass()).info(logMsg, throwable);
    }

    public static void error(Object object, String logMsg) {
        Logger.getLogger(object.getClass()).error(logMsg);
    }

    public static void error(Object object, String logMsg, Throwable throwable) {
        Logger.getLogger(object.getClass()).error(logMsg, throwable);
    }

    public static void warn(Object object, String logMsg) {
        Logger.getLogger(object.getClass()).warn(logMsg);
    }

    public static void warn(Object object, String logMsg, Throwable throwable) {
        Logger.getLogger(object.getClass()).warn(logMsg, throwable);
    }

    public static Exception errorAndThrow(Object object, String logMsg) {
        error(object, logMsg);
        return new Exception(logMsg);
    }

    public static Exception errorAndThrow(Object object, String logMsg, Throwable throwable) {
        error(object, logMsg, throwable);
        return new Exception(logMsg, throwable);
    }

    public static Exception warnAndThrow(Object object, String logMsg) {
        warn(object, logMsg);
        return new Exception(logMsg);
    }

    public static Exception warnAndThrow(Object object, String logMsg, Throwable throwable) {
        warn(object, logMsg, throwable);
        return new Exception(logMsg, throwable);
    }
}
